package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.User;
import com.zr.gdms.service.CourseService;
import com.zr.gdms.serviceimpl.CourseServiceImpl;

import net.sf.json.JSONArray;

/**
 * 成绩录入控制层
 * @author 张云辉
 *
 */
public class ShowScoreControllerZYH extends HttpServlet{
	CourseService cs = new CourseServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		HttpSession session = req.getSession();
		User u = (User) session.getAttribute("user");
		int tid  = cs.findTidByUid(u.getUid());
		JSONArray js = cs.getScoreByTid(tid);
		PrintWriter pw = resp.getWriter();
		JSONArray j = JSONArray.fromObject(js);
		pw.write(j.toString());
	}
}
